<template>
	<view>
		<view style="background-color: white;padding: 50rpx;">
			<view class="flex  flex-column" style="align-items: center; ">
				<view class="m-r-l-sm">
					<u-image width="50" height="50" :src="user.avatar ?user.avatar : ''" shape="circle"></u-image>
				</view>
				<view class="m-t-20">{{user.name}}</view>
			</view>
			<view v-if="column" class="m-t-40" style="text-align: center;">
				<uni-grid :column="column" :showBorder="false" :square="false">
					<uni-grid-item v-for="(item ,index) in grid" :key="index" class="m-t-20">
						<text style="font-size: 50rpx;">{{item.value}}</text>
						<text class="text">{{item.name}}</text>
					</uni-grid-item>
				</uni-grid>
			</view>
		</view>


		<view class="m-t-20">
			<uni-section title="常用工具" type="circle">
				<uni-list>
					<uni-list-item v-for="(item,index) in menus" :key="index" link  :to="item.url"
						:show-extra-icon="true" showArrow :extra-icon="extraIcon" :title="item.name" />
					<!-- <uni-list-item note="列表描述信息" thumb="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png" :show-extra-icon="true" showArrow :extra-icon="extraIcon" title="退出登录" /> -->
				</uni-list>
			</uni-section>
		</view>

	</view>
</template>

<script>
	import {
		wxUserUpdate,
		getWxMyUserInfo,
		loginByWxCode,
		userUpdate,
		imageUpload,
		appMenuLists
	} from '../../utils/http/http.js';
	export default {
		data() {
			return {
				user: {},
				grid: [],
				menus: [],
				column: 0,
			}
		},
		async onShow() {
			const res = await getWxMyUserInfo();
			if (!res.data.user) {
				// #ifdef MP-WEIXIN
				uni.navigateTo({
					url: '/pages/WXLogin/WXLogin'
				})
				// #endif
				
			}
			this.user = res.data.user
			this.grid = res.data.grid
			this.column = res.data.column
			if (this.user){
				this.getMenu()
			}
		},
		methods: {
			async getMenu() {
				const data = {
					all: 'all',
					type: 'user'
				};
				const res = await appMenuLists(data);
				this.menus = res.data
			}
		}

	}
</script>